package com.confee.guanglai.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.confee.guanglai.commons.GlobleConstants;
import com.confee.guanglai.domain.User;

/**
 * 员工Repository.
 * 
 * @author 李忠
 * 
 */
public interface UserRepository extends PagingAndSortingRepository<User, Long>, JpaSpecificationExecutor<User> {

	@Modifying
	@Query("update User set status=?2 where id=?1")
	public Integer modifyById(Long id, String status);

	@Query("select u from User u where u.status = '" + GlobleConstants.STATUS_NORMAL + "'")
	public Page<User> findAllUser(Pageable pageable);
	
	@Query("select u from User u where (u.no=?1 or u.name like ?2) and u.status = '" + GlobleConstants.STATUS_NORMAL + "'")
	public Page<User> findByValue(String value1, String value2, Pageable pageable);

	public User findByNoAndStatus(String no, String status);

}